<include file="Public/min-header" />
<script type="text/javascript">
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$URL_upload}";
    var URL_fileUp = "{$URL_fileUp}";
    var URL_scrawlUp = "{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$URL_getRemoteImage}";
    var URL_imageManager = "{$URL_imageManager}";
    var URL_imageUp = "{$URL_imageUp}";
    var URL_getMovie = "{$URL_getMovie}";
    var URL_home = "{$URL_home}";
</script>
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.config.js" />
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.all.js" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="__ROOT__/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title"><if condition="$act eq 'add'">增加<else />编辑</if>优惠券</h3>
                        <a href="{:U('Article/articleList')}" data-toggle="tooltip" title="" class="btn btn-primary pull-right" data-original-title="返回"><i class="fa fa-reply"></i></a>
                    </div>
                    <form class="form-horizontal" action="{:U('Promotion/c_detail')}" id="add_post"  method="post">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label"><span style="color:red;">*</span>优惠券标题</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" value="{$info.title}" name="title">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label"><span style="color:red;">*</span>使用门槛</label>
                                <div class="col-sm-1" style="line-height:32px;">
                                    <input type="text" class="form-control" value="{$info.use_price}" name="use_price" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')">
                                </div>
                                <div class="col-sm-3" style="line-height:32px;">(订单满金额后方可使用)</div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label"><span style="color:red;">*</span>优惠券面值</label>
                                <div class="col-sm-1" style="line-height:32px;">
                                    <input type="text" class="form-control" value="{$info.coupon_price}" name="coupon_price" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')">
                                </div>
                                <div class="col-sm-3" style="line-height:32px;">(订单优惠的金额)</div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label"><span style="color:red;">*</span>优惠券数量</label>
                                <div class="col-sm-1" style="line-height:32px;">
                                    <input type="text" class="form-control" value="{$info.coupon_number}" name="coupon_number" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')">
                                </div>
                                <div class="col-sm-3" style="line-height:32px;">(发放的个数)</div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">发放类型</label>
                                <div class="col-sm-3" style="line-height:32px;">
                                    <select class="form-control" name="c_type" onchange="coupon_type(this);">
                                        <option value="1" <if condition="$info['c_type'] eq 1">selected</if>>按用户注册发放</option>
                                        <option value="2" <if condition="$info['c_type'] eq 2">selected</if>>按会员即时发放</option>
                                        <option value="3" <if condition="$info['c_type'] eq 3">selected</if>>按会员购物发放</option>
                                    </select>
                                </div>
                                <div class="coupon_desc" style="line-height:34px;">(按用户进行注册后发放)</div>
                            </div>
                            <div class="form-group" <if condition="$info['c_type'] neq 2 || $info['c_type'] eq ''">style="display:none;"</if> id="coupon_type">
                                <label for="text" class="col-sm-2 control-label">发放形式</label>
                                <div class="col-sm-3" style="line-height:32px;">
                                    <select class="form-control" name="modus">
                                        <option value="1" <if condition="$info['modus'] eq 1">selected</if>>按会员注册时间</option>
                                        <option value="2" <if condition="$info['modus'] eq 2">selected</if>>按会员消费金额</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group" id="coupon_goods"  <if condition="$info['c_type'] neq 3 || $info['c_type'] eq ''">style="display:none;"</if>>
                                <label for="text" class="col-sm-2 control-label">达到购物金额</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" value="{$info.achieve_price}" name="achieve_price" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')">
                                </div>
                                <div class="col-sm-3" style="line-height:32px;">(会员购物达到此金额可获得优惠券)</div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">开始时间</label>
                                <div class="col-sm-3">
                                    <input class="control-label Wdate" name="start_time" type="text" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" <if condition="$info['start_time'] gt 0">value="{$info.start_time|date='Y-m-d H:i:s',###}"</if>>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">结束时间</label>
                                <div class="col-sm-3">
                                    <input class="control-label Wdate" name="end_time" type="text" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" <if condition="$info['end_time'] gt 0">value="{$info.end_time|date='Y-m-d H:i:s',###}"</if>>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="text" class="col-sm-2 control-label">是否显示</label>
                                <div class="col-sm-5" style="margin-top:5px;">
                                    <div class="col-sm-2">
                                        <label>
                                            <input type="radio" name="status" value="1" <if condition="$info['status'] eq 1">checked</if>> 显示 </label>
                                    </div>
                                    <div class="col-sm-2">
                                        <label>
                                            <input type="radio" name="status" value="0" <if condition="$info['status'] eq 0">checked</if>> 不显示</label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-sm-2">
                                    <input type="hidden" name="act" value="{$act}">
                                    <input type="hidden" name="id" value="{$info.id}">
                                    <input type="hidden" name="type_id" value="1">
                                </label>
                                <div class="col-sm-8">
                                    <button type="reset" class="btn btn-primary">重置</button>
                                    <button type="button" onclick="checkForm()" class="btn btn-info pull-right">提交</button>
                                </div>
                            </div>
                        </div>
                        <div class="box-footer row">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script src="__ROOT__/Public/Admin/js/date_time/WdatePicker.js"></script>
<script type="text/javascript">
    function checkForm() {
        if ($('input[name="title"]').val() == '') {
            layer.alert('请填写优惠券标题', {icon: 2 });
            return false;
        }
        if ($('input[name="use_price"]').val() == '') {
            layer.alert('请填写使用门槛', {icon: 2 });
            return false;
        }
        if ($('input[name="coupon_price"]').val() == '') {
            layer.alert('请填写优惠券面值', {icon: 2 });
            return false;
        }
        if ($('input[name="coupon_number"]').val() == '') {
            layer.alert('请填写优惠券数量', {icon: 2 });
            return false;
        }
        $('#add_post').submit();
    }
    function coupon_type(obj){
        if($(obj).val()==1){
            $('#coupon_type').hide();
            $('#coupon_goods').hide();
            $('.coupon_desc').html('(按用户进行注册后发放)');
        }else  if($(obj).val()==2){
            $('#coupon_type').show();
            $('#coupon_goods').hide();
            $('.coupon_desc').html('(按发放形式及时发放到会员)');
        }else  if($(obj).val()==3){
            $('#coupon_type').hide();
            $('#coupon_goods').show();
            $('.coupon_desc').html('(按用户购买满金额后发放)');
        }
    }
</script>
</body>
</html>
